﻿package mortal.game.view.copy.worldBoss.worldBossEnter
{
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class WorldBossIcon extends ActionBaseIcon
    {
        protected var _leftTime:SecTimerView;
        private static var _instance:WorldBossIcon;

        public function WorldBossIcon()
        {
            super(ResFileConst.WorldBossIcon);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._leftTime = UIFactory.secTimeView("mm:ss", 0, 54, 60, 20, this, GlobalStyle.textFormatHong.center());
            this._leftTime.timeOutHandler = this.timeCompl;
            this.configEventListener(MouseEvent.CLICK, this.onClickBtn);
            return;
        }// end function

        protected function onClickBtn(event:MouseEvent) : void
        {
            stopEffect();
            return;
        }// end function

        private function timeCompl() : void
        {
            this._leftTime.stop();
            this._leftTime.visible = false;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._leftTime.dispose(param1);
            super.disposeImpl(param1);
            return;
        }// end function

        public function updateOpenTime(param1:int) : void
        {
            if (param1 > 0)
            {
                this._leftTime.visible = true;
                this._leftTime.setLeftTime(param1 / 1000);
            }
            else
            {
                this._leftTime.visible = false;
            }
            return;
        }// end function

        override protected function clickHandler(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.WorldBossEnterWindowShow));
            return;
        }// end function

        public static function get instance() : WorldBossIcon
        {
            if (!_instance)
            {
                _instance = new WorldBossIcon;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
